﻿@model dynamic
@using Contrib.DecoratorField.Settings;


@{ DecoratorFieldViewModel mdl = (DecoratorFieldViewModel)Model.Model; }


@{ 
    string wtag = "<";
    switch (mdl.Settings.HtmlTag)
    {
        default:
            {
                wtag = wtag + mdl.Settings.HtmlTag.ToString();
                if (mdl.Settings.Mode != DecoMode.end )
                {
                    if (mdl.Settings.HasAttributes && !string.IsNullOrEmpty(mdl.Settings.Attributes))
                    {
                        wtag = wtag + " " + mdl.Settings.Attributes;
                    }
                    if (!string.IsNullOrEmpty(mdl.Settings.CssClass))
                    {
                        wtag = wtag + " class='" + mdl.Settings.CssClass+"'";
                    }
                    if ( mdl.Settings.Mode == DecoMode.full )
                    {
                        if(mdl.Settings.HasContent)
                        {
                            wtag = wtag + " >" + mdl.Settings.TagContent + "</" + mdl.Settings.HtmlTag.ToString()+">";
                        }
                        else
                        {
                            wtag = wtag + " />";
                        }
                    }
                    else
                    {
                        if (mdl.Settings.HasContent)
                        {
                            wtag = wtag + " >" + mdl.Settings.TagContent;
                        }
                        else
                        {
                            wtag = wtag + " >";   
                        }                        

                    }
                }
                else
                {
                    wtag = wtag + "/" + mdl.Settings.HtmlTag.ToString() + ">";
                }
            }
            break;
        case HtmlTagDisplay.br:
            wtag = wtag + "br/>";
            break;
    }

}
@Html.Raw(wtag)

